from flask import (
    Flask,
    request,
    jsonify
)
from train_test import predict
from utils import conf

app = Flask(__name__)

@app.route('/predict', methods=['POST'])
def index():
    try:
        data = request.get_json()
        result = predict(**data)
        return jsonify({'result': result}), 200
    except Exception as e:
        return jsonify({'error': str(e)}), 400

if __name__ == '__main__':
    app.run('0.0.0.0', port=5000, debug=True)
